﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using PersonalHealth.Data.Model;
using PersonalHealth.Data.IService;
using PersonalHealth.Data.Service;

namespace PersonHealth.View
{
    /// <summary>
    /// PersonPage.xaml 的交互逻辑
    /// </summary>
    public partial class PersonPage : Page
    {
        public PersonPage()
        {
            InitializeComponent();

            this.DataContext = AppData.User;

            IMessageBoardService mbSer = new MessageBoardService();
            var messageBoardList = mbSer.GetLastMessageBoardInfo();

            if (messageBoardList.Count > 0)
            {
                MessageBoardInfo.Text = messageBoardList[0].Text;
                MessageBoardDate.Text = messageBoardList[0].CreateDate.ToShortDateString();
            }
            //MessageBoardList.ItemsSource = messageBoardList;

            IMessageService mSer = new MessageService();
            int notReadMessageCount = mSer.GetNotReadMessageCount(AppData.User.Id);
            MessageInfo.Text = string.Format("[您有{0}条新的消息]", notReadMessageCount);
           
        }


        //健康测量界面
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            //NavigationService.Navigate(new Uri("../View/DetectionPage.xaml", UriKind.Relative));
            NavigationService.Content = new DetectionPage();
        }
        //完善个人资料
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            //NavigationService.Navigate(new Uri("../View/PersonInfoPage.xaml", UriKind.Relative));
            NavigationService.Content = new PersonInfoPage();
        }
        //我的消息
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            //NavigationService.Navigate(new Uri("View/MessagePage.xaml", UriKind.Relative));
            NavigationService.Content = new MessagePage();
        }
        //打印报告
        private void Button_Click_3(object sender, RoutedEventArgs e)
        {
           // NavigationService.Navigate(new Uri("View/ReportPage.xaml", UriKind.Relative));
            NavigationService.Content = new ReportPage();
        }
        //今日任务
        private void Button_Click_4(object sender, RoutedEventArgs e)
        {
            //NavigationService.Navigate(new Uri("View/TaskPage.xaml", UriKind.Relative));
            NavigationService.Content = new TaskPage();
        }
    }
}
